using HKB.Common;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
namespace HKB.Data.Dal.S_GroupTableAdapters
{
	[GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DataObject(true), HelpKeyword("vs.data.TableAdapter"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DesignerCategory("code"), ToolboxItem(true)]
	public class HL_GroupTableAdapter : Component
	{
		private SqlDataAdapter _adapter;
		private SqlConnection _connection;
		private SqlCommand[] _commandCollection;
		private bool _clearBeforeFill;
		[System.Diagnostics.DebuggerNonUserCode]
		private SqlDataAdapter Adapter
		{
			get
			{
				if (this._adapter == null)
				{
					this.InitAdapter();
				}
				return this._adapter;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		internal SqlConnection Connection
		{
			get
			{
				if (this._connection == null)
				{
					this.InitConnection();
				}
				return this._connection;
			}
			set
			{
				this._connection = value;
				if (this.Adapter.InsertCommand != null)
				{
					this.Adapter.InsertCommand.Connection = value;
				}
				if (this.Adapter.DeleteCommand != null)
				{
					this.Adapter.DeleteCommand.Connection = value;
				}
				if (this.Adapter.UpdateCommand != null)
				{
					this.Adapter.UpdateCommand.Connection = value;
				}
				for (int i = 0; i < this.CommandCollection.Length; i++)
				{
					if (this.CommandCollection[i] != null)
					{
						this.CommandCollection[i].Connection = value;
					}
				}
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		protected SqlCommand[] CommandCollection
		{
			get
			{
				if (this._commandCollection == null)
				{
					this.InitCommandCollection();
				}
				return this._commandCollection;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public bool ClearBeforeFill
		{
			get
			{
				return this._clearBeforeFill;
			}
			set
			{
				this._clearBeforeFill = value;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public HL_GroupTableAdapter()
		{
			this.ClearBeforeFill = true;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitAdapter()
		{
			this._adapter = new SqlDataAdapter();
			DataTableMapping dataTableMapping = new DataTableMapping();
			dataTableMapping.SourceTable = "Table";
			dataTableMapping.DataSetTable = "HL_Group";
			dataTableMapping.ColumnMappings.Add("GroupID", "GroupID");
			dataTableMapping.ColumnMappings.Add("GroupName", "GroupName");
			dataTableMapping.ColumnMappings.Add("GroupIntro", "GroupIntro");
			dataTableMapping.ColumnMappings.Add("GroupType", "GroupType");
			dataTableMapping.ColumnMappings.Add("SendMessage", "SendMessage");
			dataTableMapping.ColumnMappings.Add("MaxMessage", "MaxMessage");
			dataTableMapping.ColumnMappings.Add("AllowUploadSize", "AllowUploadSize");
			dataTableMapping.ColumnMappings.Add("ShoppingDiscount", "ShoppingDiscount");
			dataTableMapping.ColumnMappings.Add("OverDraft", "OverDraft");
			dataTableMapping.ColumnMappings.Add("ReCharge", "ReCharge");
			dataTableMapping.ColumnMappings.Add("Transfer", "Transfer");
			dataTableMapping.ColumnMappings.Add("TransferCharge", "TransferCharge");
			dataTableMapping.ColumnMappings.Add("AllowReadLibrary", "AllowReadLibrary");
			dataTableMapping.ColumnMappings.Add("AllowAnswerLibrary", "AllowAnswerLibrary");
			dataTableMapping.ColumnMappings.Add("AllowQuestion", "AllowQuestion");
			dataTableMapping.ColumnMappings.Add("AllowSycharArticle", "AllowSycharArticle");
			dataTableMapping.ColumnMappings.Add("AllowRss", "AllowRss");
			dataTableMapping.ColumnMappings.Add("GroupMemberNum", "GroupMemberNum");
			dataTableMapping.ColumnMappings.Add("GroupPower", "GroupPower");
			this._adapter.TableMappings.Add(dataTableMapping);
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitConnection()
		{
			this._connection = new SqlConnection();
			this._connection.ConnectionString = Conn.CurrenConnectionStrings;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitCommandCollection()
		{
			this._commandCollection = new SqlCommand[7];
			this._commandCollection[0] = new SqlCommand();
			this._commandCollection[0].Connection = this.Connection;
			this._commandCollection[0].CommandText = "SELECT GroupID, GroupName, GroupIntro, GroupType, MaxMessage, AllowUploadSize, \r\n      SendMessage, ShoppingDiscount, OverDraft, ReCharge, Transfer, TransferCharge, \r\n      AllowReadLibrary, AllowAnswerLibrary, AllowQuestion, AllowSycharArticle, AllowRss, \r\n      GroupMemberNum, GroupPower\r\nFROM HL_Group";
			this._commandCollection[0].CommandType = CommandType.Text;
			this._commandCollection[1] = new SqlCommand();
			this._commandCollection[1].Connection = this.Connection;
			this._commandCollection[1].CommandText = "DELETE  hl_group where groupid=@groupid";
			this._commandCollection[1].CommandType = CommandType.Text;
			this._commandCollection[1].Parameters.Add(new SqlParameter("@groupid", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "GroupID", DataRowVersion.Original, false, null, "", "", ""));
			this._commandCollection[2] = new SqlCommand();
			this._commandCollection[2].Connection = this.Connection;
			this._commandCollection[2].CommandText = "pr_DeleteGroupUser";
			this._commandCollection[2].CommandType = CommandType.StoredProcedure;
			this._commandCollection[2].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[2].Parameters.Add(new SqlParameter("@userid", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[2].Parameters.Add(new SqlParameter("@groupid", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[3] = new SqlCommand();
			this._commandCollection[3].Connection = this.Connection;
			this._commandCollection[3].CommandText = "SELECT HL_User.*, HL_UserInfo.*, HLShop_UserInfo.*\r\nFROM HL_User INNER JOIN\r\n      HLShop_UserInfo ON HLShop_UserInfo.U_UserID = HL_User.UserID INNER JOIN\r\n      HL_UserInfo ON HL_User.UserID = HL_UserInfo.UserID\r\nWHERE (HL_User.GroupID = @GroupID)";
			this._commandCollection[3].CommandType = CommandType.Text;
			this._commandCollection[3].Parameters.Add(new SqlParameter("@GroupID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "GroupID", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4] = new SqlCommand();
			this._commandCollection[4].Connection = this.Connection;
			this._commandCollection[4].CommandText = "INSERT INTO HL_Group\r\n      (GroupName, GroupIntro, GroupType, GroupPower)\r\nVALUES (@GroupName,@GroupIntro,@GroupType,@GroupPower)";
			this._commandCollection[4].CommandType = CommandType.Text;
			this._commandCollection[4].Parameters.Add(new SqlParameter("@GroupName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "GroupName", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4].Parameters.Add(new SqlParameter("@GroupIntro", SqlDbType.Text, 2147483647, ParameterDirection.Input, 0, 0, "GroupIntro", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4].Parameters.Add(new SqlParameter("@GroupType", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "GroupType", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4].Parameters.Add(new SqlParameter("@GroupPower", SqlDbType.VarChar, 300, ParameterDirection.Input, 0, 0, "GroupPower", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[5] = new SqlCommand();
			this._commandCollection[5].Connection = this.Connection;
			this._commandCollection[5].CommandText = "pr_Movegroupuser";
			this._commandCollection[5].CommandType = CommandType.StoredProcedure;
			this._commandCollection[5].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[5].Parameters.Add(new SqlParameter("@userid", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[5].Parameters.Add(new SqlParameter("@groupid", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[6] = new SqlCommand();
			this._commandCollection[6].Connection = this.Connection;
			this._commandCollection[6].CommandText = "UPDATE HL_Group\r\nSET GroupName = @GroupName, GroupIntro = @GroupIntro, GroupType = @GroupType, \r\n      GroupPower = @GroupPower\r\nWHERE (GroupID = @groupid)";
			this._commandCollection[6].CommandType = CommandType.Text;
			this._commandCollection[6].Parameters.Add(new SqlParameter("@GroupName", SqlDbType.NVarChar, 50, ParameterDirection.Input, 0, 0, "GroupName", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[6].Parameters.Add(new SqlParameter("@GroupIntro", SqlDbType.Text, 2147483647, ParameterDirection.Input, 0, 0, "GroupIntro", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[6].Parameters.Add(new SqlParameter("@GroupType", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "GroupType", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[6].Parameters.Add(new SqlParameter("@GroupPower", SqlDbType.VarChar, 300, ParameterDirection.Input, 0, 0, "GroupPower", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[6].Parameters.Add(new SqlParameter("@groupid", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "GroupID", DataRowVersion.Original, false, null, "", "", ""));
		}
		[DataObjectMethod(DataObjectMethodType.Fill, true), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Fill(S_Group.HL_GroupDataTable dataTable)
		{
			this.Adapter.SelectCommand = this.CommandCollection[0];
			if (this.ClearBeforeFill)
			{
				dataTable.Clear();
			}
			return this.Adapter.Fill(dataTable);
		}
		[DataObjectMethod(DataObjectMethodType.Select, true), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual S_Group.HL_GroupDataTable GetGroup()
		{
			this.Adapter.SelectCommand = this.CommandCollection[0];
			S_Group.HL_GroupDataTable hL_GroupDataTable = new S_Group.HL_GroupDataTable();
			this.Adapter.Fill(hL_GroupDataTable);
			return hL_GroupDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Fill, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int FillBy(S_Group.HL_GroupDataTable dataTable, int GroupID)
		{
			this.Adapter.SelectCommand = this.CommandCollection[3];
			this.Adapter.SelectCommand.Parameters[0].Value = GroupID;
			if (this.ClearBeforeFill)
			{
				dataTable.Clear();
			}
			return this.Adapter.Fill(dataTable);
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual S_Group.HL_GroupDataTable GetGroupUser(int GroupID)
		{
			this.Adapter.SelectCommand = this.CommandCollection[3];
			this.Adapter.SelectCommand.Parameters[0].Value = GroupID;
			S_Group.HL_GroupDataTable hL_GroupDataTable = new S_Group.HL_GroupDataTable();
			this.Adapter.Fill(hL_GroupDataTable);
			return hL_GroupDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Delete, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteGroup(int groupid)
		{
			SqlCommand sqlCommand = this.CommandCollection[1];
			sqlCommand.Parameters[0].Value = groupid;
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Update, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteGroupUser(int? userid, int? groupid)
		{
			SqlCommand sqlCommand = this.CommandCollection[2];
			if (userid.HasValue)
			{
				sqlCommand.Parameters[1].Value = userid.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			if (groupid.HasValue)
			{
				sqlCommand.Parameters[2].Value = groupid.Value;
			}
			else
			{
				sqlCommand.Parameters[2].Value = System.DBNull.Value;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Insert, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int InsertGroup(string GroupName, string GroupIntro, int? GroupType, string GroupPower)
		{
			SqlCommand sqlCommand = this.CommandCollection[4];
			if (GroupName == null)
			{
				sqlCommand.Parameters[0].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[0].Value = GroupName;
			}
			if (GroupIntro == null)
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = GroupIntro;
			}
			if (GroupType.HasValue)
			{
				sqlCommand.Parameters[2].Value = GroupType.Value;
			}
			else
			{
				sqlCommand.Parameters[2].Value = System.DBNull.Value;
			}
			if (GroupPower == null)
			{
				sqlCommand.Parameters[3].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[3].Value = GroupPower;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Update, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Movegroupuser(int? userid, int? groupid)
		{
			SqlCommand sqlCommand = this.CommandCollection[5];
			if (userid.HasValue)
			{
				sqlCommand.Parameters[1].Value = userid.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			if (groupid.HasValue)
			{
				sqlCommand.Parameters[2].Value = groupid.Value;
			}
			else
			{
				sqlCommand.Parameters[2].Value = System.DBNull.Value;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Update, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Updategroup(string GroupName, string GroupIntro, int? GroupType, string GroupPower, int groupid)
		{
			SqlCommand sqlCommand = this.CommandCollection[6];
			if (GroupName == null)
			{
				sqlCommand.Parameters[0].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[0].Value = GroupName;
			}
			if (GroupIntro == null)
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = GroupIntro;
			}
			if (GroupType.HasValue)
			{
				sqlCommand.Parameters[2].Value = GroupType.Value;
			}
			else
			{
				sqlCommand.Parameters[2].Value = System.DBNull.Value;
			}
			if (GroupPower == null)
			{
				sqlCommand.Parameters[3].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[3].Value = GroupPower;
			}
			sqlCommand.Parameters[4].Value = groupid;
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
	}
}
